﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;

namespace DAL
{
     public class Rec_RoomDAO:DALBase
    {
         private string _SpName;
         public string SpName
         {
             get { return "SpRec_Room"; }
             set { _SpName = value; }
         }
         public Rec_RoomDAO()
         {
             OpenConnect();
         }

         public bool Insert(Rec_Room obj)
         {
             try
             {
                 return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName((Rec_Room)obj, null), ConvertClassToArray.GetValues((Rec_Room)obj, 0)) == 1);
             }
             catch (Exception ex)
             {
                 throw new InvalidProgramException(ex.Message);
             }
         }
         public DataTable GetCount(long IDBD, int flag)
         {
             try
             {
                 return DBManager.Intance.ExecuteDataTable(this._SpName, new string[] { "flag", "IDBD" }, new object[] { flag, IDBD });
             }
             catch (Exception ex)
             {
                 throw new InvalidProgramException(ex.Message);
             }
         }

         public DataTable SelectAll()
         {
             try
             {
                 Rec_Room r = new Rec_Room();
                 return DBManager.Intance.ExecuteDataTable(SpName,ConvertClassToArray.GetParamName(r,null),ConvertClassToArray.GetValues(r,2));
  
             }

             catch (Exception ex)
             {
                  throw new InvalidProgramException(ex.Message);
             }
         }
         public DataTable SelectAll(String sql)
         {
             try
             {
                 return DBManager.Intance.ExecuteDataTable(sql);

             }

             catch (Exception ex)
             {
                 throw new InvalidProgramException(ex.Message);
             }
         }
    }
}
